home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / dev / lang / Python16_Src.lha / Python16_Source / Tools / scripts / fixnotice.py < prev    next >
Encoding:
Python Source  |  2000-08-03  |  2.2 KB  |  70 lines

  1. #! /usr/bin/env python
  2.  
  3. OLD_NOTICE = """\
  4. /***********************************************************
  5. Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
  6. The Netherlands.
  7.  
  8.                         All Rights Reserved
  9.  
  10. Permission to use, copy, modify, and distribute this software and its
  11. documentation for any purpose and without fee is hereby granted,
  12. provided that the above copyright notice appear in all copies and that
  13. both that copyright notice and this permission notice appear in
  14. supporting documentation, and that the names of Stichting Mathematisch
  15. Centrum or CWI or Corporation for National Research Initiatives or
  16. CNRI not be used in advertising or publicity pertaining to
  17. distribution of the software without specific, written prior
  18. permission.
  19.  
  20. While CWI is the initial source for this software, a modified version
  21. is made available by the Corporation for National Research Initiatives
  22. (CNRI) at the Internet address ftp://ftp.python.org.
  23.  
  24. STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
  25. REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
  26. MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
  27. CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
  28. DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  29. PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  30. TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  31. PERFORMANCE OF THIS SOFTWARE.
  32.  
  33. ******************************************************************/
  34.  
  35. """
  36.  
  37. NEW_NOTICE = ""
  38.  
  39. import os, sys, string
  40.  
  41. def main():
  42.     args = sys.argv[1:]
  43.     if not args:
  44.         print "No arguments."
  45.     for arg in args:
  46.         process(arg)
  47.  
  48. def process(arg):
  49.     f = open(arg)
  50.     data = f.read()
  51.     f.close()
  52.     i = string.find(data, OLD_NOTICE)
  53.     if i < 0:
  54. ##         print "No old notice in", arg
  55.         return
  56.     data = data[:i] + NEW_NOTICE + data[i+len(OLD_NOTICE):]
  57.     new = arg + ".new"
  58.     backup = arg + ".bak"
  59.     print "Replacing notice in", arg, "...",
  60.     sys.stdout.flush()
  61.     f = open(new, "w")
  62.     f.write(data)
  63.     f.close()
  64.     os.rename(arg, backup)
  65.     os.rename(new, arg)
  66.     print "done"
  67.  
  68. if __name__ == '__main__':
  69.     main()
  70.